<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/comm/mytags.jsp" %>
<!DOCTYPE>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <link rel="stylesheet" href="${ctx}/static/wxcss/apple.css">
    <link rel="stylesheet" href="${ctx}/static/wxcss/index.css">
    <script type="text/javascript" src="${ctx}/static/js/jquery-1.8.3.js"></script>
</head>
<body>
<!--title-->
<div class="header gradient_bg">
    <div class="header_logo">
        <a onclick="window.history.back()" class="header_back"> &lt </a>
        <span>登录</span>
    </div>
</div>


<div class="login_div">
    <span class="login_ltext">账号</span>
    <input id="userName" class="login_input" type="text" maxlength="11" placeholder="请输入手机号"/>
</div>
<div class="login_div">
    <span class="login_ltext">密码</span>
    <input id="password" class="login_input" type="password" maxlength="11" placeholder="请输入密码"/>
</div>
<div class="register_action"  id="loginDiv">
    <span >登录</span>
</div>

<div class="register_div">
    <a class="register_text" href="${ctx}/wxRegist">注册账号</a>
</div>

<script>
    $(function () {
        //获取所有的输入框
        var flag = true;//是否全部输入  默认true
        $(".login_input").keyup(function(){
            registerBtnShow();
        });
        function registerBtnShow() {
            $(".login_input").each(function () {
                if($(this).val()==""){
                    flag = true;
                    return false
                }else {
                    flag = false;
                }
            });
            if(flag){
                $(".register_action").removeClass("gradient_bg");
            }else{
                $(".register_action").addClass("gradient_bg");
            }
        }

        $("#loginDiv").click(function () {
            var userName = $("#userName").val();
            var password = $("#password").val();
            if(userName.trim().length === 0){
                alert("用户或手机号不可为空");
                return ;
            }else if(password.trim().length === 0){
                alert("密码不可为空");
                return;
            }
            $.ajax({
                url: "${ctx}/wxLogin.do",
                type:"post",
                dataType:"json",
                data:{
                    userName:userName,
                    password:password
                },
                success:function (res) {
                    if(res.code === 0){
                        window.location.href= "${ctx}/wxIndex";
                    }
                    else{
                        alert(res.msg);
                    }
                }
            });
        });
    })
</script>
</body>
</html>
